//
// Created by fang.junpeng on 2017/6/11.
//

#include <memory>

#ifndef CPYTHON_PYOBJ_H
#define CPYTHON_PYOBJ_H
namespace dolphin {
/**
     * a Wrap of PyObject
     */
    struct PyWrap;

    struct PyObj {
        using Obj = PyWrap;
        using Ref = std::shared_ptr<Obj>;

        PyObj();
        PyObj(const PyObj& obj);
        PyObj(PyWrap&& obj);

        PyObj&operator=(PyWrap&& wrap);

        PyObj &operator=(const PyObj &obj);

        bool valid();

        /**
         * judge if this obj is callable
         */
        bool callable();

        /**
         * call the function
         */
        PyObj call(PyObj *args, PyObj *kw = nullptr);

        /**
         * get original Object of Python
         */
        Obj *get() const;

    protected:
        Ref _obj;
    };
}

#endif //CPYTHON_PYOBJ_H
